import { useAppStoreWithOut } from '@/store';
import { Router } from 'vue-router';

export function setupRouterGuard(router: Router) {
	createProcessGuard(router);
}

/**
 * 创建进程守卫
 *
 * @param {Router} router
 */
function createProcessGuard(router: Router) {
	router.beforeEach((to: any, from: any, next: any) => {
		if (to.meta && !to.meta.ignoreAddPage) {
			const { addPage } = useAppStoreWithOut();
			addPage(to);
		}
		next();
	});
}
